package Demo.Demo2;

import java.util.Arrays;

public class Test {
    public static void main1(String[] args) {
        int[] array={0,1,2,3,4,5,6,7,8,9};
        int ret=MissNumber(array);
        System.out.println(ret);
    }
    public static  int MissNumber(int[] a)
    {
        int sum=0;
        for(int i=0;i<a.length;++i)
        {
            sum=sum+a[i];
        }
        return ((1+a.length)*a.length)/2-sum;
    }

    public static void main(String[] args) {
        int[] array={1,2,3,4,5,6,7,8,9};
        int k=5;
        rotate(array,k);
    }

        public static  void rotate(int[] nums, int k) {
            k %= nums.length;
            for(int i = 0; i < k; ++i){

                int last = nums[nums.length-1];
                for(int j = nums.length-1; j >= 1; --j){
                    nums[j] = nums[j-1];
                }

                nums[0] = last;
            }

                System.out.println(Arrays.toString(nums));

        }


}
